<%@ page import="model.*"%>
<%
Object[] grouplist = (Object[]) request.getAttribute("grouplist[]");
int[] permissions = UserGroup.getAllPermissions();
%>

<%@ include file="header.tpl.jsp"%>

<style type="text/css">
.current td{font-weight:bold;}
</style>

<div class="box list">
	<h2>User Group List</h2>
	<table>
		<thead>
			<tr>
				<td rowspan="2">User Group Name</td>
				<td colspan="8">Permission</td></tr>
			<tr>
				<td>Answer Question</td>
				<td>Add Question</td>
				<td>Edit Question</td>
				<td>Delete Question</td>
				<td>Add Paper</td>
				<td>Edit Paper</td>
				<td>Delete Paper</td>
				<td>Change Question Type</td>
			</tr>
		</thead>
		<tbody>
		<%for(int i = 0; i < grouplist.length; i++){%>
		<%UserGroup g = (UserGroup) grouplist[i]; %>
			<tr<%if(user.getGroupId() == g.getGroupId()){%> class="current"<%}%>>
				<td><%=g.getGroupName()%></td>
				<%for(int j = 0; j < permissions.length; j++){%>
				<td><%=g.hasPermission(permissions[j]) ? "Yes" : "No"%></td>
				<%}%>
			</tr>
		<%}%>
		</tbody>
	</table>
</div>

<%@ include file="footer.tpl.jsp"%>